Skip to main content

Logging

Logging is crucial for any application as it helps in monitoring and debugging application code during development. Catalyst exposes a logger instance that is installed at the global scope which can be used in server logging.


Usage

Logger provides 3 levels of logging i.e info, debug and error.

logger.info("info message")
logger.debug("debug message")
logger.error("error message")

Logs are visible in the console.


Log Format

Logs are printed in the following format.

{
level: "info",
log_level: "info",
message: "log message",
timestamp: "YYYY-MM-DD HH:mm:ss"
}

Store logs in files

Logs can be written in log file by setting the ENABLE_FILE_LOGGING key in config.json to true. Its default value is false.

Logs are cleared in 3 days and are stored in the root directory of the project.


Configuration

Logging level can be controlled by the following variables in the config.json

KeyUse
ENABLE_DEBUG_LOGSdisable debug logs in production or development
ENABLE_CONSOLE_LOGGINGcontrol console logging
ENABLE_FILE_LOGGINGcontrol file logging